// Register page module
// ====================

define(['zepto', 'sui', 'submitForm'], function($) {
  return {
    init: function() {
      this.bindReceiveClick();
    },
    bindReceiveClick: function() {
      var that = this;
      $(document).on("click", "div.active .receive", function() {
    	 var achievementId = $(this).data("achievement");
        $.ajax({
          url: window.__CTX__.root +'/profile/achievements/'+achievementId+'/receive',
          type: 'POST',
          success: function(res) {
            $.toast("领取成功", 1000)
          
            setTimeout(function(){
              window.location.reload();
            }, 1000)
          },
          error: function() {
            $.toast("领取失败");
          }
        })
      })
    }
  }
})

